//
//  ZHFAreaCell.m
//  GoTraveling
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 开发华佗. All rights reserved.
//

#import "ZHFAreaCell.h"

#import "ZHFData.h"

#import "UIImageView+WebCache.m"

#import "ZHFImageView.h"

@interface ZHFAreaCell ()

@property (nonatomic, strong) UIImageView *backgImage;

@property (nonatomic, strong) UILabel *zhName;

@property (nonatomic, strong) UILabel *enName;

@end

@implementation ZHFAreaCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}

- (void)createSubView {
    
    ZHFImageView *occupyImage = [[ZHFImageView alloc] initWithFrame:CGRectMake(10 * ADAPT_WIDTH, 10 * ADAPT_HEIGHT, SCREEN_WIDTH - 20 * ADAPT_WIDTH, 200 * ADAPT_HEIGHT)];
    occupyImage.layer.cornerRadius = 5;
    occupyImage.layer.masksToBounds = YES;
    [self.contentView addSubview:occupyImage];
    
    self.backgImage = [[UIImageView alloc] initWithFrame:CGRectMake(10 * ADAPT_WIDTH, 10 * ADAPT_HEIGHT, SCREEN_WIDTH - 20 * ADAPT_WIDTH, 200 * ADAPT_HEIGHT)];
    self.backgImage.contentMode = UIViewContentModeScaleAspectFill;
    self.backgImage.layer.masksToBounds = YES;
    self.backgImage.layer.cornerRadius = 5;
    [self.contentView addSubview:self.backgImage];
    
    self.zhName = [[UILabel alloc]initWithFrame:CGRectMake(20 * ADAPT_WIDTH, self.backgImage.frame.size.height - 55 * ADAPT_HEIGHT, SCREEN_WIDTH - 60 * ADAPT_WIDTH, 30 * ADAPT_HEIGHT)];
    
    self.zhName.textColor = [UIColor whiteColor];
    self.zhName.font = [UIFont systemFontOfSize:20 weight:0.2];
    [self.backgImage addSubview:self.zhName];
    
    self.enName = [[UILabel alloc]initWithFrame:CGRectMake(20 * ADAPT_WIDTH, self.backgImage.frame.size.height - 30 * ADAPT_HEIGHT, SCREEN_WIDTH - 60 * ADAPT_WIDTH, 30 * ADAPT_HEIGHT)];
    
    self.enName.textColor = [UIColor whiteColor];
    self.enName.font = [UIFont systemFontOfSize:18 weight:0.1];
    [self.backgImage addSubview:self.enName];
    
}

- (void)setArea:(ZHFData *)area
{
    [self.backgImage sd_setImageWithURL:[NSURL URLWithString:area.image_url]];
    self.zhName.text = area.name_zh_cn;
    self.enName.text = area.name_en;
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
